package boerse.main.Asset;

import boerse.main.Exceptions.*;

/**
 * A collection from Shares
 * @author Domi
 *
 */
public class ShareItem extends Assets {

	private long quantity;
	private Share share;
	private final long averageStartPrice;

	public ShareItem(long quantity, Share share) {
		super(share.getName());
		this.quantity = quantity;
		this.share = share;
		this.averageStartPrice = share.getPrice();
	}
	
	public long determinePrice() {
		return share.getPrice() * quantity;
	}
	
	public void addShare(long number) {
		this.quantity += number;
		
	}
	
	public void removeShare(long number) throws NegativeShareCountException {
		if ((this.quantity - number) < 0)
			throw new NegativeShareCountException("You have not enough shares");
		this.quantity -= number; 
	}

	public long getQuantity() {
		return quantity;
	}
	
	public String toString() {
		return share.toString() + ":" + quantity;
	}
	
	public long getAverageStartPrice() {
		return averageStartPrice;
	}
	
	
}